package com.singletransaction;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

//@Transactional(propagation=Propagation.REQUIRED)
@Component("userService")
public class UserServiceImpl implements UserService {

	@Resource
	private UserDao userDao;
	
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public void saveAndUpdate(UserDto userDto) {
		userDto.setId(this.userDao.add(userDto));
		userDto.setName(userDto.getName() + "a");
		this.userDao.update(userDto);
	}

}
